var ICON_SHRINK = 'layui-icon-shrink-right',
ICON_SPREAD = 'layui-icon-spread-left',
APP_SPREAD_SM = 'layadmin-side-spread-sm',
SIDE_SHRINK = 'layadmin-side-shrink',
full = 1,
status = '';

//全屏
function fullScreen(){
	if(full==1){
		var ele = document.documentElement;
		var reqFullScreen = ele.requestFullScreen || ele.webkitRequestFullScreen || ele.mozRequestFullScreen || ele.msRequestFullscreen;
		if(typeof reqFullScreen !== 'undefined' && reqFullScreen) {
			reqFullScreen.call(ele);
		};
		full = 2;
	}else{
		if (document.exitFullscreen) {
			document.exitFullscreen();
		} else if (document.mozCancelFullScreen) {
			document.mozCancelFullScreen();
		} else if (document.webkitCancelFullScreen) {
			document.webkitCancelFullScreen();
		} else if (document.msExitFullscreen) {
			document.msExitFullscreen();
		}
		full = 1;
	}
}
// 侧边伸缩
function shrink(){
	var app = $('#LAY_app'),
	iconElem=$('#LAY_app_flexible');
	//设置状态，PC：默认展开、移动：默认收缩
	if(status === 'spread'){
		//切换到展开状态的 icon，箭头：←
		iconElem.removeClass(ICON_SPREAD).addClass(ICON_SHRINK);
		//移动：从左到右位移；PC：清除多余选择器恢复默认
		if(screen() < 2){
			app.addClass(APP_SPREAD_SM);
		} else {
			app.removeClass(APP_SPREAD_SM);
		}
		app.removeClass(SIDE_SHRINK);
		status = '';
	} else {
		//切换到搜索状态的 icon，箭头：→
		iconElem.removeClass(ICON_SHRINK).addClass(ICON_SPREAD);
		//移动：清除多余选择器恢复默认；PC：从右往左收缩
		if(screen() < 2){
			app.removeClass(SIDE_SHRINK);
		} else {
			app.addClass(SIDE_SHRINK);
		}
		app.removeClass(APP_SPREAD_SM)
		status = 'spread';
	}
}
//屏幕类型
function screen(){
	var width = $(window).width();
	if(width > 1200){
		return 3; //大屏幕
	} else if(width > 992){
		return 2; //中屏幕
	} else if(width > 768){
		return 1; //小屏幕
	} else {
		return 0; //超小屏幕
	}
}
//xss 转义
function escape(html){
	return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
	.replace(/</g, '&lt;').replace(/>/g, '&gt;')
	.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
}